/*
 * Copyright (C) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef OHOS_RPC_SESSION_HANDLE_H
#define OHOS_RPC_SESSION_HANDLE_H

#include <stdbool.h>
#include <stdint.h>
#include <pthread.h>

#include "utils_list.h"

#ifdef __cplusplus
extern "C" {
#endif

#define CONNECT_WAIT_TIME_SECONDS 2

typedef struct {
    UTILS_DL_LIST idList;
    pthread_mutex_t mutex;
    pthread_cond_t condition;
    uint32_t sessionId;
    bool isReady;
} SessionIdList;

int32_t WaitForSessionIdReady(SessionIdList *sessionIdList, int32_t sessionId);
int32_t HandleNewConnection(SessionIdList *sessionIdList, int32_t sessionId);

#ifdef __cplusplus
}
#endif
#endif // OHOS_RPC_SESSION_HANDLE_H